<?php
session_start();
include('../include/util.inc.php');

if(isset($_SESSION['uid'])){
    $PDO = getPDO();
    $uid = $_SESSION['uid'];
    $sql = "SELECT * FROM history where `uid` = $uid";
    try{
        $result = $PDO->query($sql);
        $result = $result->fetchAll();
        $res = ['total' => count($result), 'detail' => $result];
        echo json_encode($res);
    }catch (PDOException $e) {
        echo $e->getMessage();
    }
    
}else{
    echo 'customer';
}
?>